package cn.net.isir.core;

import com.alibaba.fastjson.JSON;
import cn.net.isir.utils.RequestUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
 * @author liuxubo
 * @filename BasicModel.java
 * @package cn.net.isir.core
 * @email lxb@isir.net.cn
 * @date 2018/11/09
 * @comment
 * @since 1.8
 */

public class BasicModel implements Serializable {
    private static final long serialVersionUID = 1L;
    @UpdateRequired
    protected String id;
    protected String ids;//用于查询的时候，根据id进行筛选(从而不影响分页)
    protected String queryUserId;//用于查询的时候，使用此参数进行组合查询，根据某个用户(queryUserId)
    protected Integer pageNo;
    protected Integer pageSize;
    protected boolean supportPage = true;
    protected Integer isValid;
    protected String page_sql;
    /**
     * 开始时间
     */
    protected Date startTime;

    /**
     * 结束时间
     */
    protected Date endTime;

    /**
     * 扩展参数
     */
    protected Map<String, Object> extraParams;

    /**
     * 创建人
     */
    protected String createUser;

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Map<String, Object> getExtraParams() {
        return extraParams;
    }

    public void setExtraParams(Map<String, Object> extraParams) {
        this.extraParams = extraParams;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getIds() {
        return ids;
    }

    public void setIds(String ids) {
        this.ids = ids;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getQueryUserId() {
        return queryUserId;
    }

    public void setQueryUserId(String queryUserId) {
        this.queryUserId = queryUserId;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public boolean isSupportPage() {
        return supportPage;
    }

    public void setSupportPage(boolean supportPage) {
        this.supportPage = supportPage;
    }

    public Integer getIsValid() {
        return isValid;
    }

    public void setIsValid(Integer isValid) {
        this.isValid = isValid;
    }

    public String getPage_sql() {
        if (pageNo != null && pageNo > 0 && pageSize != null && pageSize > 0 && supportPage) {
            return RequestUtils.getPageSQL(pageNo, pageSize);
        }
        return null;
    }

    public void setPage_sql(String page_sql) {
        this.page_sql = page_sql;
    }
}
